package com.joy.web.base.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.joy.common.converter.BeanConverter;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName: BaseEntity
 * @Description: 基础实体
 * @Author: yjzhao
 * @Create: 2019-09-09  10:33
 **/
@Getter
@Setter
public class BaseEntity implements Serializable {

    @TableId
    private String id;

    /**
     * 是否已注销
     */
    @TableField(value = "del_yn", fill = FieldFill.INSERT)
    private String delYn;

    /**
     * 创建者ID
     */
    @TableField(value = "create_id", fill = FieldFill.INSERT)
    private String createId;

    /**
     * 创建时间
     */
    @TableField(value = "create_dts", fill = FieldFill.INSERT)
    private Date createDts;

    /**
     * 更新者ID
     */
    @TableField(value = "update_id", fill = FieldFill.INSERT_UPDATE)
    private String updateId;

    /**
     * 更新时间
     */
    @TableField(value = "update_dts", fill = FieldFill.INSERT_UPDATE)
    private Date updateDts;

    /**
     * 获取自动转换后的JavaBean对象
     *
     * @param clazz
     * @param <T>
     * @return
     */
    public <T> T convert(Class<T> clazz) {
        return BeanConverter.convert(clazz, this);
    }
}
